package com.zkingsoft.services.sys.impl;

import com.zkingsoft.services.sys.SysDbBackupService;
import com.zkingsoft.pojo.PaginationVO;
import com.zkingsoft.model.sys.SysDbBackup;
import com.zkingsoft.dao.sys.SysDbBackupDao;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.zkingsoft.exception.GlobleException;
import com.zkingsoft.util.ModelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-12-16 18:25
 */
@Service("sysDbBackupService")
public class  SysDbBackupServiceImpl implements    SysDbBackupService  {

	
	@Autowired
	private SysDbBackupDao sysDbBackupDao;
	
	
	@Override
	public int add(SysDbBackup sysDbBackup){
		
		return sysDbBackupDao.insert(sysDbBackup);
		
	}
	
	@Override
	public int batchAdd(List<SysDbBackup>  sysDbBackupList) {
		return sysDbBackupDao.batchInsert(sysDbBackupList);
	}
	
	
   	
    @Override
	public int modifyByMap(SysDbBackup oldSysDbBackup
	,SysDbBackup newSysDbBackup){
	
		if (!ModelUtils.isModified(oldSysDbBackup, newSysDbBackup)) {
			return 1;
		}
		Map<String, Object> modifyMap=null;
		try {
			modifyMap = ModelUtils.comparePojo2Map(oldSysDbBackup, newSysDbBackup);
		} catch (Exception e) {
			throw 	new GlobleException("数据对比失败");
		}
		if (modifyMap.size() > 0) {
			modifyMap.put("buId", oldSysDbBackup.getBuId());
			sysDbBackupDao.updateByMap(modifyMap);
		}
		return 1;
	}
	
	@Override
	public int modifyByModel(SysDbBackup sysDbBackup){
	
		return sysDbBackupDao.updateByModel(sysDbBackup);
	
	}
	
	
	
	@Override
	public int remove(List<Long> list){
	
		return sysDbBackupDao.deleteByIds(list);
	
	}

	@Override
	public int removeById(Long buId){
	
		return sysDbBackupDao.deleteById(buId);
	
	}
	
	@Override
	public int removeByModel(SysDbBackup sysDbBackup){
	
		return sysDbBackupDao.deleteByModel(sysDbBackup);
	
	}
	
	
	@Override
	public List<SysDbBackup> findInPage(SysDbBackup sysDbBackup,  PaginationVO pageVo){
	
		return sysDbBackupDao.selectInPage(sysDbBackup , pageVo);
	
	}
	
	@Override
	public List<SysDbBackup> findByModel(SysDbBackup sysDbBackup){
	
		return sysDbBackupDao.selectByModel(sysDbBackup);
	
	}
	
	@Override
	public int  findTotal(SysDbBackup sysDbBackup){
	
		return sysDbBackupDao.selectTotalRecord(sysDbBackup);
	
	}
	
	@Override
	public SysDbBackup  findById(Long buId){
	
		return sysDbBackupDao.selectById(buId);
	
	}

   	
	
	
}